 -- *****************************
-- *                           *
-- *    Vehicle Info Script    *   
-- *                           *
-- *****************************
--|| PROJECT:       mta-VehInfo / mta-freeroamplus
--|| DEVELOPERS:    Spanish4Life <habbos_123abc@hotmail.com>
--||                Solidsnake14 aka Castillo
--||
--|| FILE: /main.lua
-- ***************************FIRST: local's***************************
	local player = getLocalPlayer()
	local vehicle = getPedOccupiedVehicle(player)
	local vehicleID = getVehicleName(vehicle)
	local vehicleIDN = getVehicleModelFromName(vehicleID)
	local color1, color2, color3, color4, color5, color6, color7, color8, color9, color10, color11, color12 = getVehicleColor(vehicle, true)
	local whoControllIt = getVehicleController(vehicle)
	--- Door States (DS) ---
	local DS_boot = getVehicleDoorState(vehicle, 0)
	local DS_trunk = getVehicleDoorState(vehicle, 1)
	local DS_FL = getVehicleDoorState(vehicle, 2)
	local DS_FR = getVehicleDoorState(vehicle, 3)
	local DS_RL = getVehicleDoorState(vehicle, 4)
	local DS_RR = getVehicleDoorState(vehicle, 5)
	-- <eos> --
	local engine = getVehicleEngineState(vehicle)
	local L_GEAR = getVehicleLandingGearDown(vehicle)
	-- Light States (LS) --
	local LS_0 = getVehicleLightState(vehicle, 0)
	local LS_1 = getVehicleLightState(vehicle, 1)
	local LS_2 = getVehicleLightState(vehicle, 2)
	-- <eos> --
	local max_p = getVehicleMaxPassengers(vehicle)
	local v_name = getVehicleName(vehicle)
	local paintjob = getVehiclePaintjob(vehicle)
	local rX, rY, rZ = getVehicleRotation(vehicle)
	local sirens = getVehicleSirensOn(vehicle)
	local v_type = getVehicleType(vehicle)
	local FL, FR, RL, RR = getVehicleWheelStates(vehicle)
	-- Door Open States (DOS) --
	local DOS_hood = getVehicleDoorOpenRatio(vehicle, 0)
	local DOS_trunk = getVehicleDoorOpenRatio(vehicle, 1)
	local DOS_FL = getVehicleDoorOpenRatio(vehicle, 2)
	local DOS_FR = getVehicleDoorOpenRatio(vehicle, 3)
	local DOS_RL = getVehicleDoorOpenRatio(vehicle, 4)
	local DOS_RR = getVehicleDoorOpenRatio(vehicle, 5)
	-- <eos> --
-- <eos> --
--if's functions
function checkDP()
	if isVehicleDamageProof(vehicle) then
		outputChatBox("Yep, car is DP.")
	else
		outputChatBox("Not, it isn't.")
	end
end
addCommandHandler("is_dp", checkDP)

function checkFrozen()
	if isElementFrozen(vehicle) then
		outputChatBox("Your car is frozen!")
	else
		outputChatBox("Your car is not frozen.")
	end
end
addCommandHandler("is_fr", checkFrozen)

function checkFuelTank()
	if isVehicleFuelTankExplodable(vehicle) then
    outputChatBox("Fuel tank is explodable!")
	else
    outputChatBox("Fuel tank are unexplodable and secure.")
		setVehicleFuelTankExplodable(vehicle, true)
	end
end
addCommandHandler("is_exp", checkFuelTank)

function checkLock()
	if isVehicleLocked(vehicle) then
		outputChatBox("Vehicle is locked.")
	else
		outputChatBox("Vehicle isn't locked")
	end
end
addCommandHandler("is_lock", checkLock)

function checkGround()
	if isVehicleOnGround(vehicle) then
		outputChatBox("Vehicle is on ground.")
	else
		outputChatBox("Vehicle isn't on ground")
	end
end
addCommandHandler("is_ground", checkGround)

-- <eos> --
function colors()
	outputChatBox("Car colours (RGB):".. color1 .." ".. color2 .." ".. color3 .." ".. color4 .." ".. color5 .." ".. color6 .." ".. color7 .." ".. color8 .." ".. color9 .." ".. color10 .." ".. color11 .." ".. color12)
end

function controller()
	outputChatBox("Car is benig controlled by " ..whoControllIt)
end

function checkDoors()
	if DS_boot == 0 then
		outputChatBox("Boot is shut (undamaged)")
	elseif DS_boot == 1 then
		outputChatBox("Boot is open (undamaged)")
	elseif DS_boot == 2 then
		outputChatBox("Boot is shut (damaged)")
	elseif DS_boot == 3 then
		outputChatBox("Boot is open (damaged)")
	elseif DS_boot == 4 then
		outputChatBox("Boot fall off!")
	elseif DS_trunk == 0 then
		outputChatBox("Trunk is shut (undamaged)")
	elseif DS_trunk == 1 then
		outputChatBox("Trunk is open (undamaged)")
	elseif DS_trunk == 2 then
		outputChatBox("Trunk is shut (damaged)")
	elseif DS_trunk == 3 then
		outputChatBox("Trunk is open (damaged)")
	elseif DS_trunk == 4 then
		outputChatBox("Trunk fall off!")
	elseif DS_FL == 0 then
		outputChatBox("Front-Left Door is shut (undamaged)")
	elseif DS_FL == 1 then
		outputChatBox("Front-Left Door is open (undamaged)")
	elseif DS_FL == 2 then
		outputChatBox("Front-Left Door is shut (damaged)")
	elseif DS_FL == 3 then
		outputChatBox("Front-Left Door is open (damaged)")
	elseif DS_FL == 4 then
		outputChatBox("Front-Left Door fall off!")
	elseif DS_FR == 0 then
		outputChatBox("Front-Right Door is shut (undamaged)")
	elseif DS_FR == 1 then
		outputChatBox("Front-Right Door is open (undamaged)")
	elseif DS_FR == 2 then
		outputChatBox("Front-Right Door is shut (damaged)")
	elseif DS_FR == 3 then
		outputChatBox("Front-Right Door is open (damaged)")
	elseif DS_FR == 4 then
		outputChatBox("Front-Right Door fall off!")
	elseif DS_RL == 0 then
		outputChatBox("Rear-Left Door is shut (undamaged)")
	elseif DS_RL == 1 then
		outputChatBox("Rear-Left Door is open (undamaged)")
	elseif DS_RL == 2 then
		outputChatBox("Rear-Left Door is shut (damaged)")
	elseif DS_RL == 3 then
		outputChatBox("Rear-Left Door is open (damaged)")
	elseif DS_RL == 4 then
		outputChatBox("Rear-Left Door fall off!")
	elseif DS_RR == 0 then
		outputChatBox("Rear-Right Door is shut (undamaged)")
	elseif DS_RR == 1 then
		outputChatBox("Rear-Right Door is open (undamaged)")
	elseif DS_RR == 2 then
		outputChatBox("Rear-Right Door is shut (damaged)")
	elseif DS_RR == 3 then
		outputChatBox("Rear-Right Door is open (damaged)")
	elseif DS_RR == 4 then
		outputChatBox("Rear-Right Door fall off!")
	end
end

function engineState()
	outputChatBox("Your engine state is: ".. tostring(engine))
end

function landGear()
	outputChatBox("Vehicle landing gear:".. tostring(L_GEAR))
end

function lights()
	outputChatBox("Light 0:".. tostring(LS_0))
	outputChatBox("Light 1:".. tostring(LS_1))
	outputChatBox("Light 2:".. tostring(LS_2))
end

function maximumPassengers()
  outputChatBox("Maximum passengers into this vehicle: ".. tostring(max_p))
end

function paintjobs()
	outputChatBox("The paintjob of the car is: ".. tostring(paintjob))
end

function rotationCar()
	outputChatBox("Your car rotation (in degrees): ".. tostring(rX) .." ".. tostring(rY) .." ".. tostring(rZ))
end

function sirenLights()
	if (vehicleIDN == 416 or vehicleIDN == 427 or vehicleIDN == 407 or vehicleIDN == 523 or vehicleIDN == 596 or vehicleIDN == 597 or vehicleIDN == 598 or vehicleIDN == 599) then
		outputChatBox("Your sirens state are: ".. tostring(sirens))
	else
		outputChatBox("This car doesn't have sirens!")
	end
end

function vehicleTypes()
	outputChatBox("Vehicle type: ".. tostring(v_type))
end

function wheelStates()
	if FL == 0 then
		outputChatBox("Front-Left Wheel it's inflated and running")
	elseif FL == 1 then
		outputChatBox("Front-Left wheel it's pooped.")
	elseif FR == 0 then
		outputChatBox("Front-Right Wheel it's inflated and running")
	elseif FR == 1 then
		outputChatBox("Front-Right wheel it's pooped.")
	elseif RL == 0 then
		outputChatBox("Rear-Left Wheel it's inflated and running")
	elseif RL == 1 then
		outputChatBox("Rear-Left wheel it's pooped.")
	elseif RR == 0 then
		outputChatBox("Front-Right Wheel it's inflated and running")
	elseif RR == 1 then
		outputChatBox("Front-Right wheel it's pooped.")
	end
end

function openStates()
	if DOS_hood == 0 then
		outputChatBox("Hood it's closed.")
	elseif DOS_hood == 1 then
		outputChatBox("Hood it's open.")
	elseif DOS_trunk == 0 then
		outputChatBox("Trunk it's closed.")
	elseif DOS_trunk == 1 then
		outputChatBox("Trunk it's open.")
	elseif DOS_FL == 0 then
		outputChatBox("Front-Left door it's closed.")
	elseif DOS_FL == 1 then
		outputChatBox("Front-Left door it's open.")
	elseif DOS_FR == 0 then
		outputchatBox("Front-Right door it's closed.")
	elseif DOS_RL == 0 then
		outputChatBox("Rear-Left door it's closed.")
	elseif DOS_RR == 0 then
		outputChatBox("Rear-Right door it's closed.")
	elseif DOS_FR == 1 then
		outputChatBox("Front-Right door it's open.")
	elseif DOS_RL == 1 then
		outputChatBox("Rear-Left door it's open.")
	elseif DOS_RL == 1 then
		outputChatBox("Rear-Right door it's open.")
	end
end

-- command handlers.
addCommandHandler("colors", colors)
addCommandHandler("controller", controller)
addCommandHandler("doors", checkDoors)
addCommandHandler("engine", engineState)
addCommandHandler("land_gear", landGear)
addCommandHandler("lights", lights)
addCommandHandler("pass", maximumPassengers)
addCommandHandler("paintjob", paintjobs)
addCommandHandler("car_rot", rotationCar)
addCommandHandler("sirens", sirenLights)
addCommandHandler("wheels", wheelStates)
addCommandHandler("doors", openStates)